home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Diamond Collection / The Diamond Collection (Software Vault)(Digital Impact).ISO / cdr49 / vesa18.zip / VESA_TR8.C < prev    next >
C/C++ Source or Header  |  1995-01-28  |  3KB  |  112 lines

  1. /* VESA package for emx/gcc --- Copyright (c) 1993 by Johannes Martin */
  2. #include <string.h>
  3. #include <sys/hw.h>
  4.  
  5. #define INCL_VIO
  6. #define INCL_DOSPROCESS
  7.  
  8. #include <os2emx.h>
  9. #include <os2thunk.h>
  10.  
  11. #include "vgaports.h"
  12. #include "vesa.h"
  13. #include "vesadll.h"
  14. #include "common.h"
  15.  
  16. static VESAWORD _Modes[] = { 0x003, 0x012, 0x013, 0x101, 0x102, 0x103,
  17.                              0x104, 0x105, 0xFFFF };
  18.  
  19. static struct _ModeInfo _ModeInfos[] =
  20.     { { 0x1, { 0x0f, 0x7, 0x0, 64, 64, 0x0, 0x0,
  21.                OS2VesaSetWindow, OS2VesaGetWindow, 160,
  22.                640, 400, 8, 16, 1, 4, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 } },
  23.       { 0x3, { 0x1b, 0x7, 0x0, 64, 64, 0x0, 0x0,
  24.                OS2VesaSetWindow, OS2VesaGetWindow, 80,
  25.                640, 480, 8, 16, 4, 4, 1, 3, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 } },
  26.       { 0x3, { 0x1b, 0x7, 0x0, 64, 64, 0x0, 0x0,
  27.                OS2VesaSetWindow, OS2VesaGetWindow, 320,
  28.                320, 200, 8,  8, 1, 8, 1, 4, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 } },
  29.       { 0xb, { 0x1b, 0x7, 0x0, 64, 64, 0x0, 0x0,
  30.                OS2VesaSetWindow, OS2VesaGetWindow, 640,
  31.                640, 480, 8, 16, 1, 8, 1, 4, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 } },
  32.       { 0xb, { 0x1b, 0x7, 0x0, 64, 64, 0x0, 0x0,
  33.                OS2VesaSetWindow, OS2VesaGetWindow, 100,
  34.                800, 600, 8, 16, 4, 4, 1, 3, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 } },
  35.       { 0xb, { 0x1b, 0x7, 0x0, 64, 64, 0x0, 0x0,
  36.                OS2VesaSetWindow, OS2VesaGetWindow, 800,
  37.                800, 600, 8, 16, 1, 8, 1, 4, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 } },
  38.       { 0xb, { 0x1b, 0x7, 0x0, 64, 64, 0x0, 0x0,
  39.                OS2VesaSetWindow, OS2VesaGetWindow, 128,
  40.                1024, 768, 8, 16, 4, 4, 1, 3, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 } },
  41.       { 0xb, { 0x1b, 0x7, 0x0, 64, 64, 0x0, 0x0,
  42.                OS2VesaSetWindow, OS2VesaGetWindow, 1024,
  43.                1024, 768, 8, 16, 1, 8, 1, 4, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 } }
  44.     };
  45.  
  46. VESAWORD *Modes             = _Modes;
  47. struct _ModeInfo *ModeInfos = _ModeInfos;
  48.  
  49. VESABOOL Initialize(void)
  50. {
  51.   _portaccess(CRT_I, CRT_D);
  52.   _portaccess(SEG_SELECT, SEG_SELECT);
  53.   return(TRUE);
  54. }
  55.  
  56. VOID ClearUp(void)
  57. {
  58. }
  59.  
  60. VOID *GetPhysBuf(void)
  61. {
  62.   VIOMODEINFO ModeInfo;
  63.   VIOPHYSBUF  PhysBuf;
  64.  
  65.   ModeInfo.cb  = sizeof(ModeInfo);
  66.   VioGetMode(&ModeInfo, 0);
  67.   PhysBuf.pBuf = (PBYTE) ModeInfo.buf_addr;
  68.   PhysBuf.cb   = 0x10000;
  69.   if (VioGetPhysBuf(&PhysBuf, 0) != 0)
  70.     return(NULL);
  71.   else
  72.     return(MAKEP(PhysBuf.asel[0], 0));
  73. }
  74.  
  75. VESABOOL SetMode(VESAWORD mode)
  76. {
  77.   VIOMODEINFO ModeInfo;
  78.  
  79.   ModeInfo.cb     = 12;
  80.   ModeInfo.fbType = ModeInfos[mode].fbtype;
  81.   ModeInfo.color  = ModeInfos[mode].Vesa.NumberOfBitsPerPixel;
  82.   ModeInfo.col    = ModeInfos[mode].Vesa.Width  / ModeInfos[mode].Vesa.CharacterWidth;
  83.   ModeInfo.row    = ModeInfos[mode].Vesa.Height / ModeInfos[mode].Vesa.CharacterHeight;
  84.   ModeInfo.hres   = ModeInfos[mode].Vesa.Width;
  85.   ModeInfo.vres   = ModeInfos[mode].Vesa.Height;
  86.   return(VioSetMode(&ModeInfo, 0) == 0);
  87. }
  88.  
  89. void SetSpecial(VESAWORD mode)
  90. {
  91.   _outp8(SEQ_I, 0x0B);
  92.   _outp8(SEQ_D, 0x00);
  93.   _inp8(SEQ_D);
  94. }
  95.  
  96. VESABOOL OS2VesaSetWindow(VESACHAR Window, VESAWORD Address)
  97. {
  98.   _outp8(SEQ_I, 0x0B);
  99.   _outp8(SEQ_D, 0);
  100.   _inp8(SEQ_D);
  101.   _outp8(SEQ_I, 0x0E);
  102.   _outp8(SEQ_D, Address ^ 2);
  103.   return(TRUE);
  104. }
  105.  
  106. VESABOOL OS2VesaGetWindow(VESACHAR Window, PVESAWORD Address)
  107. {
  108.   _outp8(SEQ_I, 0x0E);
  109.   *Address = _inp8(SEQ_D) & 0x0F;
  110.   return(TRUE);
  111. }
  112.